package org.geo.common.exception.handler;

import org.geo.common.exception.BusinessException;
import org.geo.common.log.Log;
import org.geo.common.response.Responser;
import org.geo.common.response.model.JsonResponse;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author ljy
 */
@ControllerAdvice
@RestController
public class BusinessExceptionHandlerImpl implements IExceptionHandler<BusinessException> {
    @Override
    @ExceptionHandler(BusinessException.class)
    public JsonResponse handleException(BusinessException e) {
        Log.i(e.getMessage());
        return Responser.failed(e.getMessage());
    }
}
